<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <title>Swiper demo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
  <!-- Link Swiper's CSS -->
  <link rel="stylesheet" href="./swiper/swiper-bundle.min.css" />

  <!-- Demo styles -->
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    .bg3 {
      background: url(./imgs/bg.webp) no-repeat;
      width: 100%;
      height: 100vh;
      background-size: cover;
      background-position: center;
      position: relative;
    }

    .contain {
      position: absolute;
      background: url(./imgs/weapon-bg.png) no-repeat 0 center /contain;
      height: 600px;
      width: 1250px;
      font-size: 14px;
      /* color: #000; */
      left: 150px;
      top: 60px;
      margin: 0;
      padding: 0;
      /* background: #000; */
    }

    .swiper {
      width: 100%;
      height: 300px;
      margin-left: auto;
      margin-right: auto;
    }

    .swiper-slide {
      text-align: center;
      font-size: 18px;
      /* background: #fff; */
      background: #ece8e1;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .swiper-slide img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }



    .swiper-slide {
      background-size: cover;
      background-position: center;
    }

    /* .swiper {
      width: 100%;
      height: 300px;
      margin-left: auto;
      margin-right: auto;
    } 
      */
    /* 显示 */
    .mySwiper2 {
      height: 80%;
      width: 70%;
      position: absolute;
      left: 0;
      top: 0;

    }

    .mySwiper2 .swiper-slide {
      position: relative;
      background: transparent;
    }
    .mySwiper2 .swiper-slide  .mask{
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100px;
      height: 100px;
      background-color: pink;
    }


    /* .swiper {
      width: 100%;
      height: 300px;
      margin-left: auto;
      margin-right: auto;
    } 
      */
    /* 底部 */
    .mySwiper {
      /* height: 20%; */
      height: 600px;
      width: 300px;
      box-sizing: border-box;
      padding: 10px 0;
      /*  */
      position: absolute;
      right: 0;
      top: 0;
      background: transparent;
    }

    /* .mySwiper .swiper-wrapper{
      display: flex;
      flex-direction: column;
    } */

    /* 底部 */
    .mySwiper .swiper-slide {
      width: 100%;
      height: 100%;
      /* opacity: 0.4; */
    }

    .mySwiper .swiper-slide span {
      position: absolute;
      display: inline-block;
      left: 6px;
      bottom: 6px;
      font-size: 13px;
    }

    /* 底部 */
    .mySwiper .swiper-slide-thumb-active {
      opacity: 1;
    }

    /* 所有 */
    .swiper-slide img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
      /* background: ; */
    }
  </style>
</head>

<body>
  <div class="bg3">
    <div class="contain">
      <!-- Swiper -->
      <div style="--swiper-navigation-color: #802727; --swiper-pagination-color: #fff" class="swiper mySwiper2">
        <div class="swiper-wrapper">
          <div class="swiper-slide">
            <img src="./imgs/1.webp" />
            <div class="mask">了解更多</div>
          </div>
          <div class="swiper-slide">
            <img src="./imgs/2.webp" />
            <div class="mask">了解更多</div>
          </div>
          <div class="swiper-slide">
            <img src="./imgs/3.webp" />
            <div class="mask">了解更多</div>
          </div>
          <div class="swiper-slide">
            <img src="./imgs/4.webp" />
            <div class="mask">了解更多</div>
          </div>
          <div class="swiper-slide">
            <img src="./imgs/5.webp" />
            <div class="mask">了解更多</div>
          </div>
        </div>
        <!-- <div class="swiper-button-next"></div>
        <div class="swiper-button-prev"></div> -->
      </div>
      <!-- 底部 -->
      <div thumbsSlider="" class="swiper mySwiper">
        <div class="swiper-wrapper">
          <div class="swiper-slide">
            <img src="./imgs/1.webp" />
            <span>短炮</span>
          </div>
          <div class="swiper-slide">
            <img src="./imgs/2.webp" />
            <span>短炮</span>
          </div>
          <div class="swiper-slide">
            <img src="./imgs/3.webp" />
            <span>短炮</span>
          </div>
          <div class="swiper-slide">
            <img src="./imgs/4.webp" />
            <span>短炮</span>
          </div>
          <div class="swiper-slide">
            <img src="./imgs/5.webp" />
            <span>短炮</span>
          </div>
        </div>
      </div>
    </div>
  </div>



  <!-- Swiper JS -->
  <script src="./swiper/swiper-bundle.min.js"></script>

  <!-- Initialize Swiper -->
  <script>
    // 底部
    var swiper = new Swiper(".mySwiper", {

      direction: 'vertical',
      spaceBetween: 10,
      slidesPerView: 4,
      freeMode: true,
      watchSlidesProgress: true,
      on: {
        // 点击事件添加背景
        click: function (swiper, event) {
          // alert('事件触发了;');
          var slides = swiper.slides;
          slides.forEach(function (slide) {
            slide.style.background = '';
          });
          var clickedSlide = event.target.closest('.swiper-slide');
          if (clickedSlide) {
            clickedSlide.style.background = "url(./imgs/select.webp)";
          }
        },
        slideChange: function () {

        }

      },
    });

    // 初始化，刚刚进入页面，默认显示第一张图片
    if (swiper.slides.length > 0) {
      swiper.slides[0].style.backgroundImage = "url(./imgs/select.webp)";
    }

    // 上部
    var swiper2 = new Swiper(".mySwiper2", {
      spaceBetween: 10,
      // 垂直
      direction: 'vertical',
      effect: "fade",
      // 淡入淡出效果的配置选项，不要覆盖
      fadeEffect: {
        crossFade: true, // 启用交叉淡入淡出效果
      },

      // navigation: {
      //   nextEl: ".swiper-button-next",
      //   prevEl: ".swiper-button-prev",
      // },
      // 不允许触碰翻页
      allowTouchMove: false,
      thumbs: {
        swiper: swiper,
      },
    });
  </script>
</body>

</html>